<template>
	<view class="ad-card" :style="{ background: adData.bgColor }">
		<view class="ad-header">
			<text class="ad-tag">广告</text>
			<view class="ad-actions">
				<text class="ad-action" @click="handleClose">×</text>
			</view>
		</view>
		<view class="ad-content" @click="handleClick">
			<view class="ad-image-container">
				<image class="ad-image" :src="adData.image" mode="aspectFill"></image>
			</view>
			<view class="ad-text">
				<text class="ad-title">{{ adData.title }}</text>
				<text class="ad-desc">{{ adData.desc }}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "AdCard",
		props: {
			adData: {
				type: Object,
				default: () => ({})
			}
		},
		methods: {
			handleClick() {
				this.$emit('adClick', this.adData);
			},
			handleClose() {
				this.$emit('adClose', this.adData);
			}
		}
	}
</script>

<style scoped>
	.ad-card {
		border-radius: 16rpx;
		padding: 24rpx;
		border: 1rpx solid #ffecec;
		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
	}

	.ad-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.ad-tag {
		font-size: 20rpx;
		color: #999;
		background: #f0f0f0;
		padding: 4rpx 12rpx;
		border-radius: 12rpx;
	}

	.ad-actions {
		display: flex;
		align-items: center;
	}

	.ad-action {
		font-size: 28rpx;
		color: #999;
		width: 40rpx;
		height: 40rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 50%;
		background: #f5f5f5;
		cursor: pointer;
	}

	.ad-content {
		display: flex;
		align-items: center;
		gap: 20rpx;
	}

	.ad-image-container {
		width: 120rpx;
		height: 120rpx;
		flex-shrink: 0;
	}

	.ad-image {
		width: 100%;
		height: 100%;
		border-radius: 12rpx;
		background-color: #f5f5f5;
	}

	.ad-text {
		flex: 1;
	}

	.ad-title {
		display: block;
		font-size: 28rpx;
		color: #ff6b6b;
		font-weight: 600;
		margin-bottom: 8rpx;
	}

	.ad-desc {
		font-size: 24rpx;
		color: #999;
		line-height: 1.4;
	}
</style>